package organism;
import java.util.Random;

public class Arthropod extends Organism {

	/**
	 * Arthropod class moves around an abstract area with given coordinates, direction, and speed.
	 * It also has numLegs.
	 * 
	 * @param numLegs is the number of legs of the Arthropod creature.
	 */
	
	private int numLegs;
	private Random rand = new Random();
	
	public Arthropod(String name, int xCoord, int yCoord, int speed, String direction, int numLegs){
		super(name, xCoord, yCoord, direction, speed);
		
		this.numLegs = numLegs;
	}
	
	@Override
	public void move(){
		/**
		 * Move Arthropod class in a random direction using java.util.Random.
		 */
		//super.direction = "south";
		//The above is bad coding, and should NOT be done;
		//it changes the parent's attributes.
		//Which goes against the idea of encapsulation and has other problems
		//Such as: we require knowledge of how the parent Class stores its fields(Instance variables)
		
		int randomInt = rand.nextInt(3); // Store a random int 1,2,3,4 in randomInt
		super.direction = Organism.VALID_DIRECTIONS[randomInt];//Changes directions randomly.
		super.move();
			}

	public int getNumLegs() {
		return numLegs;
	}

	public void setNumLegs(int numLegs) {
		this.numLegs = numLegs;
	}
	
	@Override
	public String toString(){
		/**
		 * Uses Superclass Organism's toString, but appends the number
		 * of legs of Arthropod numlegs.
		 */
		
		return super.toString() + " " + Integer.toString(numLegs);
	}
	
	

}
